<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>数组</title>
    <script type="text/javascript">
        // var score1 = 100;
        // var score2 = 30;
        // var score3 = 20;
        //数组可以存储一组数据
        // var arr1 = new Array();
        // arr1[0] = 100;
        // arr1[1] = 30;
        // arr1[2] = 60;
        // arr1[3] = "sikiedu.com";// arr1[3] = 70;
        // arr1[4] = 80;
        // arr1[5] = 90;
        // console.log(arr1[3]);//70 //注释掉arr1[3] = 70; 打印结果是undefined //字符串arr1[3]="sikiedu.com";居然也能打印出来。
        // console.log(arr1.length);//6 //注释掉arr1[3] = 70; 打印结果仍然是6

        // for(var i=0;i<arr1.length;i++){
        //     console.log(arr1[i]);
        // }

        // var arr2 = new Array(10);
        // for(var i = 0;i < arr2.length;i++){
        //     console.log(arr2[i]);//undefined
        // }

        // var arr3 = new Array(90,80,50,40);
        // var arr3 = new Array("李白","孙尚香","夏侯惇");
        // for(var i = 0;i<arr3.length;i++){
        //     console.log(arr3[i]);
        // }

        function user(name,age,sex){
            this.name = name;
            this.age = age;
            this.sex = sex;
        }
        user1 = new user("李白",90,"男");
        user2 = new user("孙尚香",30,"女");
        user3 = new user("夏侯惇",20,"男");

        var arr = new Array(user1,user2,user3);
        for(var i = 0;i<arr.length;i++){
            // console.log(arr[i].name);
            console.log(arr[i].age);
        }
    </script>
</head>
<body>
    
</body>
</html>